<template name='user_gorup'>

<view style="display: flex;    height: 100%;">
	<!-- 商品信息-右边 -->
	<view class="box-infos font12  " >


			<!-- 记录 -->
			<view class="content-box">
				<view class="boxsss100" >
					<!-- 增加、删除 -->
					
					<view class="top-but">
						<view class="top-but-box background-fff">
							<text selectable="true"   class="tipss ">用户分组；常用于客户群体、商品类型区分及限制</text>
							<!-- 搜索 -->
						
							<button @click="$common.noMultipleClicks('loadGroup',loadGroup,true)" 
							class="leftBut color1" 
							>
								<img src="../../static/img/search.png" class="ico" ></img>
								刷新
							</button>
							<button
							@click="group_add()"
							class="leftBut color2">
								<img src="../../static/img/add.png" class="img"></img>
								增加
							</button>
						</view>
					</view>
					<table v-if="resData.list!=undefined && resData.list.length>0">
						<!-- 表头 -->
						<thead>
							<tr >
								<th  class="centers ">
									序
								</th>
								
								<th>
									名称(点击可进行修改名称)
								</th>
								<th>
									用户数
								</th>
								<th>
									操作
								</th>
							</tr>
						</thead>
						<tbody>
							<!-- 内容 -->
							<tr v-for="(item,index) in resData.list"
							:key="index"
							@click="TabcheckedIndex = index"
							:class="TabcheckedIndex == index ? 'goods-list-select':''"
							class="font14"
							v-if="item.id.length>0 "
							>
								<td selectable="true"   class="centers ">
									{{index+1}}
								</td>
								
								<td selectable="true"   
								class="cursor" 
								:title="$global.title.m28+'\nid：'+item.id"
								>
									<input
									:disabled="item.id==0"
									:auto-height="true"
									v-model="item.name" 
									@confirm="group_update(item.name,item.id)"
									class="centers white-space goodsNameColor font14"
									/>
								</td>
								
								<td selectable="true"  class="centers" 
								@click="openUserList(item.id,item.name)"
								>
									<text class="alter ">{{item.user_count}}</text>
								</td>
								
								<td selectable="true"   class="color-e40318" 
								@click="groupDelete(item.id)"
								>
									删除
								</td>
							</tr>
						</tbody>
					</table>
					
					<!-- 暂无数据 -->
					<empty v-if="resData.list==undefined || resData.list.length==0"></empty>
					<!-- end -->
				</view>
			</view>
			
		

	</view>

	
	
	<!-- 用户页面 -->
	<uni-popup ref="pageUser" type="center" :title="pageSend.name">
		<person_admin  class="h100" :OnGoruplId="pageSend.id" status="firm_user_list"></person_admin>
	</uni-popup>
	<!-- end -->
</view>
</template>

<script>

	import empty from "@/components/admin-components/empty.vue"
	export default{
		name:'user_gorup',
		components: {
			empty,
		},
		beforeCreate(){
			this.$options.components.person_admin = require('@/components/user/list.vue').default 
		},
		data(){
			return{
				TabcheckedIndex:-1,
				pageSend:{//欲要传递到权限页面搜寻的内容
					id:'',//可能是user_id,goods_id
					name:''
				},
			
				resData:{
					list:[]
				},
			}
		},
		 // 此处定义传入的数据
		props: {
		},
		beforeUpdate(){
			
		},
		created() {
			this.loadGroup();
		},
		onShow() {
		},
		methods:{
			openUserList(id,name){
				this.pageSend.name = name+"下的用户"
				this.pageSend.id = id
				this.$refs.pageUser.open()
			},
			loadGroup(){
				var that = this
				that.$routeData.loadGroup(()=>{
					that.resData.list = that.$routeData.getGroup()
				})
			},
			group_update(name,id){
				var that = this
				this.$routeData.group_update(name,id,()=>{
					that.resData.list = that.$routeData.getGroup()
				})
			},
			groupDelete(id){
				var that = this
				this.$routeData.groupDelete(id,()=>{
					that.resData.list = that.$routeData.getGroup()
				})
			},
			group_add(){
				var that = this
				this.$routeData.group_add(()=>{
					that.resData.list = that.$routeData.getGroup()
				})
			}
		}
	}
</script>

<style>
</style>
